package cat20032010;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.Timer;

/**
*
* @author aDeeY
*/

public class WaiterFrame extends javax.swing.JFrame {
    Timer timer = new Timer(1000, new TimerListener());
    static WaiterLogin WaiterLogin = new WaiterLogin();
    static Waiter Waiter = new Waiter();

    public WaiterFrame() {
        initComponents();
        setLocationRelativeTo(null);
        update();
        Waiter.setVisible(true);
        timer.start();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jtfDate = new javax.swing.JTextField();
        jtfCurrentTime = new javax.swing.JTextField();
        jpServiceOption = new javax.swing.JPanel();
        jpServicePanel = new javax.swing.JPanel();
        jlBackground = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jPanel1.setLayout(null);

        jtfDate.setEditable(false);
        jtfDate.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jtfDate.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jtfDate.setText("jTextField1");
        jtfDate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfDateActionPerformed(evt);
            }
        });
        jPanel1.add(jtfDate);
        jtfDate.setBounds(360, 30, 150, 20);

        jtfCurrentTime.setEditable(false);
        jtfCurrentTime.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jtfCurrentTime.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        jtfCurrentTime.setText("jTextField1");
        jtfCurrentTime.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfCurrentTimeActionPerformed(evt);
            }
        });
        jPanel1.add(jtfCurrentTime);
        jtfCurrentTime.setBounds(170, 30, 150, 20);

        jpServiceOption.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jpServiceOption.setLayout(null);

        jpServicePanel.setMinimumSize(new java.awt.Dimension(630, 470));
        jpServicePanel.setLayout(null);
        jpServiceOption.add(jpServicePanel);
        jpServicePanel.setBounds(10, 10, 630, 470);
        jpServicePanel.setVisible(true);

        jpServicePanel.add(Waiter);
        Waiter.setBounds(10, 10, 620, 460);
        Waiter.setVisible(false);

        jPanel1.add(jpServiceOption);
        jpServiceOption.setBounds(20, 70, 650, 490);

        jlBackground.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cat20032010/shipbackground.jpg"))); // NOI18N
        jPanel1.add(jlBackground);
        jlBackground.setBounds(0, 0, 690, 580);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 690, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jtfCurrentTimeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfCurrentTimeActionPerformed
    }//GEN-LAST:event_jtfCurrentTimeActionPerformed

    private void jtfDateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfDateActionPerformed
    }//GEN-LAST:event_jtfDateActionPerformed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new WaiterFrame().setVisible(true);
            }
        });
    }
    
    public void update() {
        Date currentDate = new Date();
        Date currentTime = new Date();

        time++;
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
        SimpleDateFormat formattertime = new SimpleDateFormat("hh:mm:ss");
        String dateString = formatter.format(currentTime);
        String timeString = formattertime.format(currentDate);
        jtfDate.setText(dateString);
        jtfCurrentTime.setText(timeString);
        //JOptionPane.showMessageDialog(null, "test3");
    }
    
    public int time = 0;
    public Timer timer1;

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel jlBackground;
    private javax.swing.JPanel jpServiceOption;
    private javax.swing.JPanel jpServicePanel;
    private javax.swing.JTextField jtfCurrentTime;
    private javax.swing.JTextField jtfDate;
    // End of variables declaration//GEN-END:variables
        
    private class TimerListener implements ActionListener{
	   public void actionPerformed(ActionEvent e){
		   update();
	   }
   }

}

